package com.lc202407;

public class Solution3099 {
    public int sumOfTheDigitsOfHarshadNumber(int x) {
        int total = 0;
        int copy = x;
        while (copy / 10 != 0) {
            total += copy % 10;
            copy = copy / 10;
        }
        total += copy;
        if (x % total == 0) {
            return total;
        }
        return -1;
    }
}
